.PHONY: all build

# project relate variables
PROJECTNAME=$(shell basename "$(PWD)")
DOCKER_REGISTRY="152.136.134.100:10048"

# Go related variables.
GOBASE=$(shell pwd)
all: iot-car-build-arm7

iot-car-build:
	@go build -mod vendor -o $(GOBASE)/deploy/docker/apis $(GOBASE)/cmd/manager/apis/main.go
	@chmod a+x $(GOBASE)/deploy/docker/apis
	@docker build --build-arg EXEC_FILE="apis" -t $(PROJECTNAME)-apis $(GOBASE)/deploy/docker/
	@docker tag $(PROJECTNAME)-apis:latest $(DOCKER_REGISTRY)/glue-apis:latest
	@docker push $(DOCKER_REGISTRY)/glue-apis:latest
	@docker rmi $(PROJECTNAME)-apis:latest $(DOCKER_REGISTRY)/glue-apis:latest
	@kubectl apply -f $(GOBASE)/deploy/yaml/apis.yaml

iot-car-build-arm7:
	@GOOS=linux GOARCH=arm GOARM=7 go build -mod vendor -o ./strategy ./main.go
	@chmod a+x ./strategy
	@docker build --build-arg EXEC_FILE="strategy" -t gluenet/test.strategy:arm7 .
